<?php

namespace App\Http\Validate\OpenShop\ShopLocation;

use App\Enums\OpenShop\InvestmentPromotion\SignOrderEnum;
use App\Http\Validate\AbstractBaseValidate;
use Illuminate\Support\MessageBag;
use Illuminate\Validation\Rule;
use Illuminate\Validation\ValidationException;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;

/**
 * [ 订单业务验证 ] - 校验规则
 *
 * @OpenShopUserContractValidate
 * @package App\Http\Controllers
 * @date 2022/03/01 02:35:56
 * @author GreenLeaf <786407418@qq.com>
 */
class OrderValidate extends AbstractBaseValidate
{
    public function registerValidateRules(): void
    {
        // TODO: Implement registerValidateRules() method.
    }

    public function getAttributes(): array
    {
        // TODO: Implement getAttributes() method.
        return [
            "orderNo" => "签约订单号"
        ];
    }

    public function getMessages(): array
    {
        // TODO: Implement getMessages() method.
        return [
            "orderNo.exists" => "当前订单号暂不支持查看支付信息"
        ];
    }

    public function getRules(): array
    {
        // TODO: Implement getRules() method.
        return [
            'orderNo' => [
                "required",
                "string",
                "exists" => Rule::exists("open_shop_sign_order", "orderNo")
//                    ->whereIn("payStatus", [
//                        SignOrderEnum::PAY_STATUS_PART,
//                        SignOrderEnum::PAY_STATUS_OK
//                    ])
            ],
        ];
    }

    /**
     * @param array $data
     * @return MessageBag|object
     * @throws ValidationException
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public static function payDetailValidate(array $data)
    {
        return self::getInstance()->validate(['orderNo'], $data);
    }
}
